﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;

namespace ExamSharedClasses {
    /// <summary>
    /// (k) Die Basisklasse für die Klausurfragen, die nur das wichtigste enthält
    /// und der gleichnamigen Datenbanktabelle entspricht.
    /// </summary>
    [Serializable()]
    public class Question {
        public const String TABLENAME = "question";
        public const String QUESTION_ID = "question_id";
        public const String QUESTION_TYPE = "question_type";
        public const String QUESTION_NUMBER = "question_number";

        public int QuestionId { get; set; }                 //-k entspricht einmaliger FragenId
        public int QuestionNumber { get; set; }             //-k entspricht einmaliger FragenId im Fragen-Typen-Kontext
        public string QuestionTypeObject { get; set; }      //-k typ-string, 'multiple', 'single_multiple', 'text', 'image'

        public Question() : this( -1, -1, "" ) { }
        public Question( Question question ) : this (question.QuestionId, question.QuestionNumber, question.QuestionTypeObject) {}
        public Question( int questionId, int questionNumber, string questionTypeObject) {
            this.QuestionId = questionId;
            this.QuestionNumber = questionNumber;
            this.QuestionTypeObject = questionTypeObject;
        }

        public string ToShortInfoString() {
            StringBuilder sb = new StringBuilder( "(ID: " + QuestionId + " Typ: ");
            if (QuestionTypeObject.Equals("text"))
                sb.Append( "Text" );
            else if (QuestionTypeObject.Equals("single_multiple"))
                sb.Append( "SingleChoiceOfMultiple" );
            else if (QuestionTypeObject.Equals("multiple"))
                sb.Append( "Multiple-Choice" );
            sb.Append( " )");
            return sb.ToString();
        }

        public override string ToString() {
            StringBuilder sb = new StringBuilder( ToShortInfoString() );
            return sb.ToString();
        }
        public virtual string ToMoreDetailedString() {
            return "";
        }
    }
}
